package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.system.mapper.AdminQuestionMapper;
import com.ruoyi.system.domain.AdminQuestion;
import com.ruoyi.system.service.IAdminQuestionService;
import com.ruoyi.common.core.text.Convert;

/**
 * 选择题Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-06-17
 */
@Service
public class AdminQuestionServiceImpl implements IAdminQuestionService 
{
    @Autowired
    private AdminQuestionMapper adminQuestionMapper;

    /**
     * 查询选择题
     * 
     * @param questionId 选择题ID
     * @return 选择题
     */
    @Override
    public AdminQuestion selectAdminQuestionById(Long questionId)
    {
        return adminQuestionMapper.selectAdminQuestionById(questionId);
    }

    /**
     * 查询选择题列表
     * 
     * @param adminQuestion 选择题
     * @return 选择题
     */
    @Override
    public List<AdminQuestion> selectAdminQuestionList(AdminQuestion adminQuestion)
    {
        return adminQuestionMapper.selectAdminQuestionList(adminQuestion);
    }

    /**
     * 新增选择题
     * 
     * @param adminQuestion 选择题
     * @return 结果
     */
    @Override
    public int insertAdminQuestion(AdminQuestion adminQuestion)
    {
        adminQuestion.setCreateTime(DateUtils.getNowDate());
        return adminQuestionMapper.insertAdminQuestion(adminQuestion);
    }

    /**
     * 修改选择题
     * 
     * @param adminQuestion 选择题
     * @return 结果
     */
    @Override
    public int updateAdminQuestion(AdminQuestion adminQuestion)
    {
        adminQuestion.setUpdateTime(DateUtils.getNowDate());
        return adminQuestionMapper.updateAdminQuestion(adminQuestion);
    }

    /**
     * 删除选择题对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAdminQuestionByIds(String ids)
    {
        return adminQuestionMapper.deleteAdminQuestionByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除选择题信息
     * 
     * @param questionId 选择题ID
     * @return 结果
     */
    @Override
    public int deleteAdminQuestionById(Long questionId)
    {
        return adminQuestionMapper.deleteAdminQuestionById(questionId);
    }
    
    /**
     * 选择题状态修改
     * 
     * @param question 选择题信息
     * @return 结果
     */
    @Override
    public int changeStatus(AdminQuestion adminQuestion)
    {
        return adminQuestionMapper.updateAdminQuestion(adminQuestion);
    }
}
